package com.example.service.impl;

import com.example.dao.AttendanceDao;
import com.example.dao.CensusDao;
import com.example.po.Attendance;
import com.example.po.CensusAttendance;
import com.example.po.CensusCount;
import com.example.service.AttendanceService;
import com.example.service.CensusService;
import com.example.utils.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 与统计相关业务逻辑类
 */
@Service
public class CensusServiceImpl implements CensusService {
    @Autowired
    private CensusDao censusDao;
    @Override
    public List<CensusCount> cansusCount(HttpSession session) {
        Page page= (Page) session.getAttribute("page");
        if(page==null){
            page=new Page();
            page.setCount(10);
            page.setStart(1);
            page.setTotal(censusDao.findAllCount());
        }
        session.setAttribute("page",page);
        PageHelper.startPage(page.getStart(),page.getCount());
        return censusDao.cansusCount();
    }

    @Override
    public List<CensusAttendance> cansusAttendanceCount(HttpSession session) {
        return censusDao.cansusAttendanceCount();
    }
}
